#ifndef ALP_ICONV_H
#define ALP_ICONV_H

/**
 * @file	alp_iconv.h
 * @brief	Charset conversion.
 */

#include "alp_type.h"
/** Abstract type for iconv. */
typedef struct alp_iconv_t alp_iconv_t;

/**
 * Create a new iconv for character set conversion.
 * @param newic    the iconv just created
 * @param fromcode the source charset
 * @param tocode   the target charset
 * @param pool     the pool to allocate an iconv out of
 * @return 0 for OK
 */
int alp_iconv_create(alp_iconv_t **newic, const char* fromcode, const char* tocode);

/**
 * Do conversion.
 * @param ic       the iconv
 * @param inbuf    the input buffer
 * @param inlen    on input, the source buffer length; on output, the length consumed
 * @param outbuf   the output buffer
 * @param outlen   on input, the target buffer length; on output, the length written
 * @return 0 for OK
 */
int alp_iconv(alp_iconv_t *ic, const char *inbuf, size_t *inlen, char *outbuf, size_t *outlen);

/**
 * Create a new iconv for character set conversion.
 * @param ic       the iconv
 * @return 0 for OK
 */
int alp_iconv_destroy(alp_iconv_t *ic);

/**
 * Get the pool which the iconv is created in.
 * @param ic       the iconv
 * @return the pool associated with the iconv
 */
//int alp_iconv_pool_get(alp_iconv_t *ic);

#endif
